<?php

namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;


class MailController extends Controller
{
    // 发送邮件测试
    public function initialize()
    {
        parent::initialize();
    }

    // 测试
    // https://slh.shenlannews.com/test/mail/send
    // 深蓝汇发送邮件
    // lisen1004@qq.com
    // SClzliuxu231590
    // 授权码（在qq邮箱中设置获取）
    // fekerjeqpfiobhga
    public function send()
    {
        $email = '23231590@qq.com';
        $code  = rand(1000, 9999);

        //使用blade模板发送(引用的模板)
        // Mail::send(模板文件, [参数], function($message) use ($email) {});
        Mail::send('emails.email', ['code' => $code], function($message) use ($email) {
            $message->to($email)->subject('深蓝汇');
        });
        if(Mail::failures()){
            return ["code" => 0, "msg" => "error"];
        }

        return ["code" => 1, "msg" => "success"];
    }

}



